package cn.com.bluemoon.daps.common.exception;


import cn.com.bluemoon.daps.common.domain.ResultBean;

/**
 * 项目异常，捕获后返回前端
 * {@see GlobalExceptionHandler#methodArgumentNotValid(HttpServletRequest, MethodArgumentNotValidException)}
 * @author Jarod.Kong
 */
public class DapException extends RuntimeException{

    private Integer code;
    private String message;

    public DapException(String msg){
        super(msg);
        this.code = ResultBean.FAIL_CODE;
        this.message = msg;
    }

    public DapException(String message, Throwable cause) {
        super(message, cause);
        this.message = message;
    }

    /**
     * 自定义错误信息
     * @param message
     * @param code
     */
    public DapException(String message, Integer code) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}

